#include <iostream>
using namespace std;
#include <cstring>
#include <list>
#include <cstdio>

int main() {
	char str[21];
	scanf("%s", str);
	int len = strlen(str);
	list<char>l;
	char c;
	int pos;
	for (int i = 0; i < len; i++) {
		l.push_back(str[i]);
	}

	while (len != 0) {
		char temp;
		int sum1 = 0;
		int sum2 = 0;
		getchar();
		scanf("%c %d", &c, &pos);

		auto it = l.begin();

		for (int i = 0; i < pos - 1; i++) {
			it++;
		}
		l.insert(it, c);
		len++;
		it--;
		auto it1 = it;
		if (it == l.begin()) {
			;
		} else {
			while ((it1--) != l.begin()) {
				if (*it1 == c) {
					sum1++;
				} else {
					break;
				}
			}
		}

		it1 = it;

		while ((++it1) != l.end()) {
			if (*it1 == c) {
				sum2++;
			} else {
				break;
			}
		}



		if (sum1 + sum2 + 1 >= 3) {
			it1 = it;
			it1++;
			for (int i = 0; i < sum2; i++) {
				it1 = l.erase(it1);
				if (it1 == l.end()) {
					break;
				}
			}
			it1 = it;

			for (int i = 0; i < sum1; i++) {
				if (it1 != l.begin()) {
					it1--;
				}
			}

			for (int i = 0; i < sum2 + 1; i++) {
				if (it1 != l.end()) {
					it1 = l.erase(it1);
				}

			}
			len -= sum1 + sum2 + 1;

			if (len == 0) {
				printf("You win!");
				return 0;
			}
		}
		it = l.begin();
		while (it != l.end()) {
			printf("%c", *it);
			it++;
		}

		printf("\n\n");

	}

}